<script type="text/javascript">
Ext.onReady(function(){
    Ext.QuickTips.init();

    var notesPanel = new Ext.Panel({
        id : "rm_myreservations_list_note_panel",
        renderTo: 'rm_myreservations_list_note',
        frame: false,
        layout: 'anchor',
        title: 'Notes',
        items: [{
            xtype: 'textarea',
            anchor: "100%",
            height: 150,
            ref: 'noteText',
            disabled: true
        }],
        bbar: [{
            xtype: 'button',
            text: RM.Translate.User.MyReservations.List.ResendNotes,
            ref: '../sendButton',
            disabled: true,
            handler: function(){
                Ext.Ajax.request({
                    url : RM.Common.AssembleURL({
                        controller: 'MyReservations_List',
                        action: 'notesJson'
                    }),
                    params: {
                        reservationID: RM_MyReservations_List_GetSelected().reservation_id,
                        notes: notesPanel.noteText.getValue()
                    },
                    method: 'POST',
                    success: function(responseObject) {
                        Ext.Msg.alert('Status', RM.Translate.User.MyReservations.List.NotesSent);
                    },
                    failure: function() {
                        Ext.Msg.alert('Status', RM.Translate.Common.UnableToShow);
                    }
                });
            }
        }]
    });

    if (typeof(RM_MyReservations_List_Grid) !== 'undefined') {
        RM_MyReservations_List_Grid.getSelectionModel().addListener(
            'rowselect',
            function(selectionModel, rowNumber, record) {
                notesPanel.sendButton.enable();
                notesPanel.noteText.enable();
                notesPanel.noteText.setValue(record.data.notes);
            }
        );
    }
});
</script>
<div id="<?php echo $this->panel->getDivID() ?>">
    <div id="rm_myreservations_list_note"></div>   
</div>